package nl.saxion.database.beerology;

import java.util.GregorianCalendar;

import android.database.sqlite.SQLiteDatabase;

import nl.saxion.activity.beerology.Hoofdmenu;
import nl.saxion.model.beerology.Review;

public class DatabaseQuery
{

	private static SQLiteDatabase sqlite;
	
	private static void getDatabase()
	{
		DatabaseManager databaseManager = Hoofdmenu.getDatabaseManager();
		sqlite = databaseManager.getReadableDatabase();
	}
	
	public static void newReview(Review review)
	{
		if(sqlite == null)
		{
			getDatabase();
		}

		GregorianCalendar now = new GregorianCalendar();
		String datum = now.get(GregorianCalendar.DAY_OF_MONTH) + "-" + now.get(GregorianCalendar.MONTH) + "-" +
						now.get(GregorianCalendar.YEAR) + "-";
				
		sqlite.execSQL("INSERT INTO Reviews (geschonken_id, datum, locatie, rating, opmerking)" +
						" VALUES (" + review.getType() + ", '" +datum + "', '" +review.getLocation() + "', " +
						review.getRating() + "'" + review.getRemark() + "');"
						);
	}
}
